<?php
    class sscls_ArticleModel extends sscls_Model
    {   

        function __construct()
        {
            parent::__construct();
        }
       function getArticles()
	   {
			$query='select 
							a.id as idArticle,
							a.*,b.name as username,c.name as catname 
					from article as a 
					left join users as b on a.userid=b.id
					left join categories as c on a.catid=c.id';
					
			return $this->_db->loadObjectList($query);
	   }
	   
		function getCategories()
		
		{
			$query='select * from categories';
			return $this->_db->loadObjectList($query);
			
		}
	   
	   function store1($data,$tablename)
	   {
			$result=$this->store($data,$tablename);
			return $result;
	   }
	   
	   function getItem($id)
	   {
			return $this->_db->loadObject('select * from article where id='.$id);
	   }
	   
	   function remove($ids)
	   {
		if(is_array($ids))
			$sql='delete from article where id in ('.implode(',',$ids).')';
		else
			$sql='delete from article where id ='.(int)$ids;
		return $this->_db->query($sql);
	   }
    }
?>
